<?php
namespace Home\Controller;
use Think\Controller;
class EnrollController extends Controller {
    public function enroll(){
        $this->display();
    }    
    public function addUser(){
        $user['user']=I('post.user');
        $user['password']=I('post.password');
        $enroll=M('enroll_user');
        $data=$enroll->add($user);
        if($data){
        	$this->success('恭喜你注册成功了',U('Login/login'));
        }else{
        	$this->error('恭喜你注册失败了');
        }
    }
    public function ajaxCheckUser(){
        $username=$_POST['user'];
        $user=M('enroll_user');
        $res=$user->where("user='".$username."'")->select();
        if(count($res)>0){
            $r=false; 
        }else{
            $r=true;
        }
        $this->ajaxReturn($r);
    }
}